<#import "../space_macro.ftl" as space />
<#include "../header.ftl" />
		<@side.sidenav active="文章管理"/>
	    <div class="g-content">
	        <div class="g-content-container">
	            <div class="g-p">
					<div class="m-crumb">
					    <ul class="f-cb">
					        <li><i>&gt;</i><a href="#">博客管理</a></li>
					        <li><i>&gt;</i><a href="#">文章管理</a></li>
					    </ul>
					</div>
					<div class="page-title">
						<h1>文章管理</h1>
					</div>
					<div class="m-content">
						<form name="postForm" id="postForm" action="${spaceUrl}/admin/post/list" method="GET">
							<@spring.bind "postPage" />
							<!-- pagination parameter -->
							<@spring.formHiddenInput path="postPage.pageNo" />
							<@spring.formHiddenInput path="postPage.totalPages" />
							<@spring.formHiddenInput path="postPage.totalCount" />
							<!-- sorter parameter -->
							<@spring.formHiddenInput path="postPage.sortEnable" />
							<@spring.formHiddenInput path="postPage.sort.field" />
							<@spring.formHiddenInput path="postPage.sort.order" />
							
						    <div class="none">
						    	<#if (postPage?exists && postPage.result?size > 0)>
						        	<#list postPage.result as post>
								    	<div class="media">
								    		<div class="media-body">
								    			<div class="media-body-title">
								    				<strong>${post.title}</strong>
								    				<small class="f-fr">
								    					<a style="color:#ec5524;" href="javascript:deletePost(this, ${post.id});">删除</a>
								    					<a style="color:#ec5524;" href="${spaceUrl}/admin/post/edit?id=${post.id}">修改</a>
								    				</small>
								    			</div>
								    			<p class="typo-small"><@contentTransform content="${post.content}" removeHtml=true substring=true endIndex=200 /></p>
								    			<p class="typo-small">
								    				创建时间：${post.createTime}
								    				分类：<#if (post.catalogs?exists && post.catalogs?size > 0)><#list post.catalogs as catalog>${catalog.name}&nbsp;</#list></#if>
								    				查看：${post.viewCount}&nbsp;&nbsp;&nbsp;&nbsp;
								    			</p>
							    			</div>
							    		</div>
							    	</#list>
					        	</#if>
						    </div>
						    <#if (postPage.totalPages > 1)>
		                        <@space.pagenavi pageEntity=postPage baseUrl=spaceUrl + "/admin/post/list?pageNo=$page$" />
		                    </#if>
						</form>
					</div>
	            </div>
	        </div>
	    </div>
	    <script type="text/javascript">
	    	function deletePost(o, postId){
	    		if(!confirm('确认删除该文章吗？')){
	    			return;
	    		}
	    		$.post('${spaceUrl}/admin/post/delete?id=' + postId, function(){
	    			var pageNo = $('#pageNo').val();
	    			var url = '${spaceUrl}/admin/post/list';
	    			if(pageNo){
	    				url = url + '?pageNo=' + pageNo;
	    			}
	    			window.location.href = url;
	    		});
	    	}
	    </script>
<#include "../footer.ftl" />